package com.ruanyun.modular.admin.controller;

import com.ruanyun.base.pojo.page.LayuiPageInfo;
import com.ruanyun.modular.admin.entity.TBasicinfo;
import com.ruanyun.modular.admin.entity.VocReducingPlan;
import com.ruanyun.modular.admin.model.params.VocReducingPlanParam;
import com.ruanyun.modular.admin.model.result.ReduceResult;
import com.ruanyun.modular.admin.service.VocReducingPlanService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * VOCs综合减排措施控制器
 *
 * @author zs
 * @Date 2021-04-19 16:11:38
 */
@Controller
@RequestMapping("/vocReducingPlan")
public class VocReducingPlanController extends BaseController {

    private String PREFIX = "/vocReducingPlan";

    @Autowired
    private VocReducingPlanService vocReducingPlanService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/vocReducingPlan.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/vocReducingPlan_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/vocReducingPlan_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(VocReducingPlanParam vocReducingPlanParam) {
        return this.vocReducingPlanService.add(vocReducingPlanParam);
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(VocReducingPlanParam vocReducingPlanParam) {
        return this.vocReducingPlanService.update(vocReducingPlanParam);
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(VocReducingPlanParam vocReducingPlanParam) {
        return this.vocReducingPlanService.updateDelFlagById((long)vocReducingPlanParam.getId());
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2021-04-19
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(VocReducingPlanParam vocReducingPlanParam) {
        VocReducingPlan detail = this.vocReducingPlanService.getById(vocReducingPlanParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(VocReducingPlanParam vocReducingPlanParam) {
        return this.vocReducingPlanService.findPageBySpec(vocReducingPlanParam);
    }

    /**
     * 启用
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/enable")
    public ResponseData enable(@RequestParam Long id) {
        return this.vocReducingPlanService.enableById(id);
    }

    /**
     * 禁用
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/disable")
    public ResponseData disable(@RequestParam Long id) {
        return this.vocReducingPlanService.disableById(id);
    }



    /**
     * 查询列表
     *
     * @author zs
     * @Date 2021-04-16
     */
    @ResponseBody
    @RequestMapping("/planList")
    public List<VocReducingPlan> getList() {
        return this.vocReducingPlanService.getList();
    }




    /**
     * 编辑源头替代页面
     *
     * @author zs
     * @Date 2021-05-11
     */
    @RequestMapping("/sourceEdit")
    public String sourceEdit() {
        return PREFIX + "/sourceEdit.html";
    }




    /**
     * 查询减排措施列表 第一次跳转
     *
     * @author zs
     * @Date 2021-04-19
     */
    @ResponseBody
    @RequestMapping("/sourceList")
    public LayuiPageInfo  sourceList(Integer redId, Integer redType) {
        return vocReducingPlanService.sourceList(redId,redType);
    }

    /**
     * 编辑强制性措施页面
     *
     * @author zs
     * @Date 2021-05-11
     */
    @RequestMapping("/mandatory")
    public String mandatory() {
        return PREFIX + "/mandatory.html";
    }

}


